import request from '@/utils/request'

// 分页列表
export function list (data) {
    return request({
        url: '/school/work/workPage',
        method: 'post',
        data
    })
}

// 详情
export function getById (query) {
    return request({
        url: '/school/work/getById/' + query.id,
        method: 'get',
        params: query
    })
}

// 新增
export function add (data) {
    return request({
        url: '/school/work/add',
        method: 'post',
        data: data
    })
}

// 修改
export function edit (data) {
    return request({
        url: '/school/work/edit',
        method: 'put',
        data: data
    })
}

// 删除
export function deleteById (data) {
    return request({
        url: '/school/work/deleteById/' + data.id,
        method: 'delete',
        data
    })
}

// 获取该学校的等级列表
export function getList (query) {
    return request({
        url: '/school/work/getList',
        method: 'get',
        params: query
    })
}

// 获取所有的等级列表
export function getListV2 (query) {
    return request({
        url: '/school/work/getListV2',
        method: 'get',
        params: query
    })
}

// 分页获取等级列表
export function levelPage (query) {
    return request({
        url: '/school/work/levelPage/',
        method: 'get',
        params: query
    })
}

// 根据学生id获取实验作业分页列表
export function getListByStudentId (params) {
    return request({
        url: '/school/work/getListByStudentId/' + params.id,
        method: 'get',
        params
    })
}

// 根据班级名称获取班级实验列表
export function classExperiment (query) {
    return request({
        url: '/school/work/classExperiment',
        method: 'get',
        params: query
    })
}


// 根据学生名称获取异常作业分页列表
export function getErrorListByStudentName (query) {
    return request({
        url: '/school/work/getErrorListByStudentName',
        method: 'get',
        params: query
    })
}

export const apiScoreDetail = (id) => {
  return request({
    url: `/school/testPaperDetails/getById/` + id,
    method: 'get'
  })
}

export const apiSchoolWorkSave = (id, currentHtml) => {
  return request({
    url: `/school/testPaperDetails/score`,
    method: 'put',
    data: {
      id,
      gradingContent: currentHtml,
      testPaperStatus: 2
    }
  })
}
